package com.ezhou.hy.common.persistance;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.NamingException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ezhou.hy.common.transaction.JDBCConnectionManagerImlp;
import com.ezhou.hy.exception.ConnectionException;



/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>CopyRight:Copyright (c) 2008.12 </p>
 * <p>Company: </p>
 * @author Haiger
 * @version 1.0
 */

public class PersistanceImpl implements Persistance{
	
	private Connection      conn;
	private PreparedStatement ps;
	private ResultSet         rs;      
	
	private Log log = LogFactory.getLog(PersistanceImpl.class);
	
	public PersistanceImpl(){
		
	}
	
    protected Connection getConnection() throws NamingException, SQLException, ClassNotFoundException{
		conn = JDBCConnectionManagerImlp.getInstance().getConnection();
		
		return conn;
	}

    public int addBatch(){
    	return 0;
    }
	public int addBatch(String sql) {
//		getPreparedStatement(sql).addBatch();
		return 0;
	}

	public int execute() {
		return 0;
	}

	public ResultSet executeQuery(String sql){

//		rs = getPreparedStatement(sql).executeQuery();
	
		return null;
	}

	public int executeUpdate(String sql) {
//		getPreparedStatement(sql).executeUpdate();
		return 0;
	}
	
	protected PreparedStatement getPreparedStatement(String sql) throws ConnectionException{
		try {
			return getConnection().prepareStatement(sql);
		} catch (Exception e) {
			log.error("getPreparedStatement Exception in "+this.toString());
			throw new ConnectionException("getPreparedStatement Exception in "+this.toString());
		}
	}

  
}
